﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace TimePickerTesting
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                List<DateTime> list = new List<DateTime>();
                list.Add(DateTime.Now);
                list.Add(DateTime.Now.AddSeconds(30));
                list.Add(DateTime.Now.AddMinutes(30));

                TimeSelectorAvailabilityValidator1.AppointmentList = list;
                TimeSelectorAvailabilityValidator1.AppointmentLengthInMinutes = 90;

                FormView1.DataSource = list;
                FormView1.DataBind();
            }
        }

        public List<DateTime> getSampleDateTimeList()
        {
            List<DateTime> list = new List<DateTime>();
            list.Add(DateTime.Now);
            list.Add(DateTime.Now.AddSeconds(30));
            list.Add(DateTime.Now.AddMinutes(30));

            return list;
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                lblTS1.Text = TimeSelector1.Date.ToLongDateString() + ", " + TimeSelector1.Date.ToLongTimeString();
                lblTS2.Text = TimeSelector2.Date.ToLongDateString() + ", " + TimeSelector2.Date.ToLongTimeString();
                lblTS3.Text = TimeSelector3.Date.ToLongDateString() + ", " + TimeSelector3.Date.ToLongTimeString();
                lblTS4.Text = TimeSelector4.Date.ToLongDateString() + ", " + TimeSelector4.Date.ToLongTimeString();
                lblTS5.Text = TimeSelector5.Date.ToLongDateString() + ", " + TimeSelector5.Date.ToString("HH:mm:ss");
                lblAjax.Text = TimeSelector6.Date.ToLongDateString() + ", " + TimeSelector6.Date.ToLongTimeString();
                lblTS7.Text = TimeSelector7.Date.ToLongDateString() + ", " + TimeSelector7.Date.ToLongTimeString();
            }
        }

        protected void btnAjax_Click(object sender, EventArgs e)
        {
            TimeSelector6.Date = DateTime.Now;
        }

        protected void btnSwitchToItemViewMode_Click(object sender, EventArgs e)
        {
            FormView1.ChangeMode(FormViewMode.ReadOnly);
        }

        protected void btnSwitchToEditMode_Click(object sender, EventArgs e)
        {
            FormView1.ChangeMode(FormViewMode.Edit);
        }

        protected void btnSwitchToInsertMode_Click(object sender, EventArgs e)
        {
            FormView1.ChangeMode(FormViewMode.Insert);
        }
    }
}

